#include "../../include/DictProducer2.h"
#include "../../include/SplitToolCppJieba.h"
#include <chrono>
#include <iostream>

using std::cout;
using std::endl;

int main(void) {
    // 获取程序开始时间点
    auto start = std::chrono::high_resolution_clock::now();

    Configuration *conf = Configuration::getInstance();
    SplitToolCppJieba split;

    string path = conf->getInstance()->getConfigValue("CN_ART_PATH");
    DictProducer CnDict(path, &split);
    string Dictpath = conf->getInstance()->getConfigValue("CN_DICT_OUTPUT_PATH");
    string Indexpath = conf->getInstance()->getConfigValue("CN_INDEX_OUTPUT_PATH");

    string enPath = conf->getInstance()->getConfigValue("EN_ART_PATH");
    DictProducer EnDict(enPath);
    string EnDictPath = conf->getInstance()->getConfigValue("EN_DICT_OUTPUT_PATH");
    string EnIndexPath = conf->getInstance()->getConfigValue("EN_INDEX_OUTPUT_PATH");


    CnDict.buildCnDict();
    CnDict.storeCnDict(Dictpath);
    CnDict.buildCnIndex();
    CnDict.storeCnIndex(Indexpath);

    EnDict.buildEnDict();
    EnDict.storeEnDict(EnDictPath);
    EnDict.buildEnIndex();
    EnDict.storeEnIndex(EnIndexPath);

    EnDict.createDictTable("t_en_dict");
    CnDict.createDictTable("t_cn_dict");
    CnDict.createIndexTable("t_cn_index");
    EnDict.createIndexTable("t_en_index");

    // 获取程序结束时间点
    auto end = std::chrono::high_resolution_clock::now();
    // 计算程序执行时间
    std::chrono::duration<double> duration = end - start;
    double executionTime = duration.count();

    // 打印程序执行时间
    LogInfo("Running Time：%lf s", executionTime);
}

